'use strict';

/**
 * @ngdoc directive
 * @name jgappApp.directive:chatusers
 * @description
 * # chatusers
 */
angular.module('jgappApp')
    .directive('chatusers', ["$window", "$rootScope", "$location", "RongYService", "ChatStatus", "Groups", function ($window, $rootScope, $location, RongYService, ChatStatus, Groups) {
        return {
            scope:{
                confirm: "=confirm"
            },
            replace: true,
            template: '<div class="chat-users fs12 flex" ng-show="userArr&&userArr.length">' +
            '<div class="w85 scrollx">' +
            '<div class="chat-userlist" style="min-width:{{listwidth}}px">' +
            '<div class="item-avtar lh35 tc" ng-repeat="item in userArr track by item.id"><img err-src="images/404.png" ng-src={{item.iconCls|avtarfilter}} alt="" ng-if="item.iconCls">{{item.name|username}}</div>' +
            '</div>' +
            '</div>' +
            '<div class="w15 btn fs14" ng-click="submit()">确定</div>' +
            '</div>',
            restrict: 'AE',
            link: function postLink(scope, element, attrs) {
                // element.text('this is the logList directive');
                $rootScope.$on("userArrchange", function () {
                    scope.userArr = $rootScope.userArr
                    scope.listwidth = $rootScope.userArr.length * 40
                })
                scope.listwidth = $rootScope.userArr && $rootScope.userArr.length * 40 || 0
                scope.submit = function () {
                   scope.confirm();
                }
            }
        };
    }]);
